<?php
class ModelConfigPosition extends Model {
	
	public function getTotalPositions() {
      	$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "config_position`");
		return $query->row['total'];
	}
	
	public function getPosition($position_id) {
		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "config_position` WHERE position_id = '" . (int)$position_id . "'");
		return $query->row;
	}
	
	public function getPositions($data = array()) {
		$sql = "SELECT * FROM `" . DB_PREFIX . "config_position`";
			
		$sort_data = array(
			'date_added'
		);	
			
		if (isset($data['start']) || isset($data['limit'])) {
			if ($data['start'] < 0) {
				$data['start'] = 0;
			}			
			
			if ($data['limit'] < 1) {
				$data['limit'] = 20;
			}	
			
			$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
		}
		$query = $this->db->query($sql);
		return $query->rows;
	}
	
	
	public function getPositionInfo($data = array(),$searchData = array()){
		
		if($data&&count($data)==2){
			$results = $this->getPositions($searchData);
			
		}
		return false;
	}
	
}
?>